﻿// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using ImageMagick;
using Xunit;

namespace Magick.NET.Tests;

public partial class MagickImageTests
{
    public class TheAdaptiveSharpenMethod
    {
        [Fact]
        public void ShouldSharpenTheImage()
        {
            using var image = new MagickImage(Files.MagickNETIconPNG);
            image.AdaptiveSharpen(10, 10);
#if Q8 || Q16
            ColorAssert.Equal(new MagickColor("#a95ce07af952"), image, 56, 68);
#else
            ColorAssert.Equal(new MagickColor("#a8a8dfdff8f8"), image, 56, 68);
#endif
        }

        [Fact]
        public void ShouldUseTheCorrectDefaultValuesWithoutArguments()
        {
            using var imageA = new MagickImage(Files.MagickNETIconPNG);
            using var imageB = imageA.Clone();
            imageA.AdaptiveSharpen();
            imageB.AdaptiveSharpen(0.0, 1.0);

            var distortion = imageA.Compare(imageB, ErrorMetric.RootMeanSquared);
            Assert.Equal(0.0, distortion);
        }

        [Fact]
        public void ShouldUseTheCorrectDefaultValuesWithChannels()
        {
            using var imageA = new MagickImage(Files.MagickNETIconPNG);
            using var imageB = imageA.Clone();
            imageA.AdaptiveSharpen(Channels.Red);
            imageB.AdaptiveSharpen(0.0, 1.0, Channels.Red);

            var distortion = imageA.Compare(imageB, ErrorMetric.RootMeanSquared);
            Assert.Equal(0.0, distortion);
        }
    }
}
